home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
doc
/
homepage
/
tv.lzh
/
tv
/
scripts
/
r.tcl
Wrap
Text File
|
1995-12-24
|
10KB
|
431 lines
vstkInit
proc Frame {fr channel val} {
global TvObj
set no [lindex [$channel configure -text] 4]
set obj $TvObj($no)
vsGet3DMovieInfo $obj cur max loop
#vsGet3DMovieInfo $obj cur max
#vsGet3DMovieInfo $obj cur
incr cur $val
if {$cur < 0} {
set cur [expr $max - 1]
}
if {$cur >= $max} {
set cur 0
#vsMessageDlg "$cur"
}
vsSet3DMovieFrame $obj $cur
vsGet3DMovieInfo $obj cur mmax
$fr configure -text $cur
#vsMessageDlg "$cur $max $loop"
}
proc ChCtrl {obj ev data} {
if {$data == "up"} {
set val 1
} else {
set val -1
}
Channel .frame8.lchannel $val
}
proc VolCtrl {obj ev data} {
if {$data == "up"} {
set val 10
} else {
set val -10
}
Volume .frame10.lspeed .frame8.lchannel $val
}
proc Pause {obj} {
global TvObj
set l [lindex [$obj configure -text] 4]
if {$l == "Pause"} {
set no [lindex [.frame8.lchannel configure -text] 4]
vsPause3DMovie $TvObj($no)
vsStopSoundByName channel$no
set l Play
} else {
PlayChannel
set l Pause
.frame11.lspeed configure -text "***"
}
$obj configure -text $l
}
proc ObjVisible {obj flg} {
global vsCSWorld vsAbsolute vsObjAttrVisible
vsSetObjAttribute $obj $vsObjAttrVisible $flg
}
proc PowerPick {obj ev user} {
OnOff .frame0.button2 1
}
proc TvInit {obj ev no} {
global TvObj vsFalse
vsGetObjByName $obj a
#vsMessageDlg "$no"
set TvObj($no) $obj
if {! $no} {
return
}
ObjVisible $obj $vsFalse
}
proc SuspendAll {} {
global TvObj vsTrue vsFalse
foreach d {1 2 3} {
ObjVisible $TvObj($d) $vsFalse
vsPause3DMovie $TvObj($d)
vsStopSoundByName channel$d
}
ObjVisible $TvObj(0) $vsTrue
}
proc ResetChanDisp {} {
global TvObj vsTrue vsFalse vsDiffuse vsTransparency
foreach d { 1 2 3 } {
set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.CH$d]
vsSetObjAllMaterial $pb $vsDiffuse 0.7 1.0 0.7
vsSetObjAllMaterial $pb $vsTransparency 1.0
}
}
##################################
# Display (Channel Display) clean Timeouthandler Id
##################################
set RmChThId 0
proc HideChanDisp {notuse ev user} {
global RmChThId
ResetChanDisp
set RmThId 0
}
proc ShowChanDisp {no} {
global vsDiffuse vsTransparency RmChThId
global vsTclScript vsSporadicTask
set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.CH$no]
vsSetObjAllMaterial $pb $vsTransparency 0.0
# pb is only dummy.
if {$RmChThId} {
vsRemoveTimeOutHandler $pb $RmChThId
}
set RmThId [vsAddTimeOutHandler "$pb" 6200 \
$vsTclScript "" HideChanDisp \
"data" $vsSporadicTask]
}
proc PlayChannel {} {
global TvObj vsTrue vsFalse vsDiffuse vsTransparency
set no [lindex [.frame8.lchannel configure -text] 4]
ObjVisible $TvObj($no) $vsTrue
ObjVisible $TvObj(0) $vsFalse
vsPlay3DMovie $TvObj($no)
vsPlayAmbientSoundByName channel$no $vsTrue
ResetChanDisp
ShowChanDisp $no
}
proc ResetVolBar {} {
global vsTransparency vsDiffuse
for {set i 1} { $i <= 10 } {incr i} {
set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.VOL$i]
vsSetObjAllMaterial $pb $vsTransparency 1.0
vsSetObjAllMaterial $pb $vsDiffuse 0.3 0.3 0.3
}
}
##################################
# Display clean Timeouthandler Id
##################################
set RmThId 0
proc HideVolBar {notuse ev user} {
global RmThId
ResetVolBar
set RmThId 0
}
proc ShowVolBar {vol} {
global RmThId
global vsTransparency vsDiffuse vsTclScript vsSporadicTask
for {set i 1} { $i <= 10 } {incr i} {
set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.VOL$i]
vsSetObjAllMaterial $pb $vsTransparency 0.0
if { $i <= $vol } {
vsSetObjAllMaterial $pb $vsDiffuse 0.7 1.0 0.7
}
}
# pb is only dummy.
if {$RmThId} {
vsRemoveTimeOutHandler $pb $RmThId
}
set RmThId [vsAddTimeOutHandler "$pb" 2200 \
$vsTclScript "" HideVolBar \
"data" $vsSporadicTask]
}
proc Volume {obj channel flg} {
#vsMessageDlg vol
set vol [lindex [$obj configure -text] 4]
set vol [expr $vol + $flg]
if {$vol > 100} {
set vol 100
}
if {$vol < 0} {
set vol 0
}
set no [lindex [$channel configure -text] 4]
#vsMessageDlg [expr 256 / 100 * $vol]
vsSetSoundVolumeByName channel$no [expr 256 / 100 * $vol]
ResetVolBar
ShowVolBar "[expr $vol / 10]"
$obj configure -text $vol
}
proc Channel {obj flg} {
global TvObj vsObjAttrVisible vsTrue vsFalse
set now [ lindex [$obj configure -text] 4 ]
incr now $flg
if {$now > 3} {
set now 1
}
if {$now < 1} {
set now 3
}
$obj configure -text $now
set tvobj $TvObj($now)
if {[ lindex [ .frame0.button2 configure -text] 4 ] == "Off"} {
SuspendAll
PlayChannel
}
}
proc OnOff {obj sound} {
global TvObj vsFalse vsTrue vsDiffuse
#set pb [vsGetObjByName TV.Button.CH1]
set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.Power]
#set pb [vsGetObjByName world.Power]
set now [ lindex [$obj configure -text] 4 ]
if {$now == "On"} {
set lab Off
# power ON. TODO...
vsPlayAmbientSoundByName power $vsFalse
PlayChannel
.frame0.label1 configure -background green
vsSetObjAllMaterial $pb $vsDiffuse 0.0 1.0 0.0
wm deiconify .
} else {
set lab On
SuspendAll
.frame0.label1 configure -background gray
vsSetObjAllMaterial $pb $vsDiffuse 1.0 0.0 0.0
#wm withdraw .
}
$obj configure -text $lab
}
proc Control {mode} {
global TvObj
set now [ lindex [.frame8.lchannel configure -text] 4 ]
set speed [vsGet3DMovieSpeed $TvObj($now)]
switch $mode {
up { set v 0.1}
down { set v -0.1}
}
set vv [expr $v + $speed]
.frame3.lspeed configure -text $vv
set now [lindex [.frame8.lchannel configure -text] 4]
vsSet3DMovieSpeed $TvObj($now) $vv
#Pause .frame11.bpause
#Pause .frame11.bpause
}
# procedure to show window .
proc ShowWindow. {args} {# xf ignore me 7
# Window manager configurations
global tkVersion
wm positionfrom . user
wm sizefrom . ""
wm maxsize . 1280 1024
wm title . {Remote control}
# build widget .frame0
frame .frame0 \
-borderwidth {2} \
-relief {raised}
# build widget .frame0.label1
label .frame0.label1 \
-relief {sunken} \
-background gray \
-text {Power}
# build widget .frame0.button2
button .frame0.button2 \
-text {On} -command "OnOff .frame0.button2 1"
# pack widget .frame0
pack append .frame0 \
.frame0.label1 {left frame center expand fillx} \
.frame0.button2 {top frame center}
# build widget .frame3
frame .frame3 \
-borderwidth {2}
# build widget .frame3.lspeed
label .frame3.lsd \
-relief {sunken} \
-text {Speed}
label .frame3.lspeed \
-text {1.0}
# build widget .frame3.bfor
button .frame3.bfor \
-text {->} -command "Control up"
# build widget .frame3.bback
button .frame3.bback \
-text {<-} -command "Control down"
# pack widget .frame3
pack append .frame3 \
.frame3.lsd {left frame n expand fillx} \
.frame3.bback {left frame nw} \
.frame3.lspeed {left frame n expand fillx} \
.frame3.bfor {left frame nw}
# build widget .frame8
frame .frame8 \
-borderwidth {2}
label .frame8.lcl \
-relief {sunken} \
-text {Channel}
# build widget .frame8.bcback
button .frame8.bcback \
-text {<-} -command "Channel .frame8.lchannel -1"
# build widget .frame8.bcfor
button .frame8.bcfor \
-text {->} -command "Channel .frame8.lchannel 1"
# build widget .frame8.lchannel
label .frame8.lchannel \
-relief {groove} \
-text {1}
# pack widget .frame8
pack append .frame8 \
.frame8.lcl {left frame nw expand fillx} \
.frame8.bcback {left frame nw} \
.frame8.lchannel {left frame nw expand fillx} \
.frame8.bcfor {left frame nw}
#################
# build widget .frame10
frame .frame10 \
-borderwidth {2}
# build widget .frame10.lspeed
button .frame10.lvol \
-relief {sunken} \
-text {Volume}
label .frame10.lspeed \
-text {100}
# build widget .frame10.bfor
button .frame10.bfor \
-text {->} -command "Volume .frame10.lspeed .frame8.lchannel 10"
# build widget .frame10.bback
button .frame10.bback \
-text {<-} -command "Volume .frame10.lspeed .frame8.lchannel -10"
# pack widget .frame10
pack append .frame10 \
.frame10.lvol {left frame n expand fillx} \
.frame10.bback {left frame nw} \
.frame10.lspeed {left frame n expand fillx} \
.frame10.bfor {left frame nw}
# build widget .frame11
frame .frame11 \
-borderwidth {2}
# build widget .frame11.bpause
button .frame11.bpause \
-text {Pause} -command "Pause .frame11.bpause"
# build widget .frame11.lspeed
label .frame11.lspeed \
-text {***}
# build widget .frame11.bfor
button .frame11.bfor \
-text {->} -command "Frame .frame11.lspeed .frame8.lchannel 1"
# build widget .frame11.bback
button .frame11.bback \
-text {<-} -command "Frame .frame11.lspeed .frame8.lchannel -1"
# pack widget .frame11
pack append .frame11 \
.frame11.bpause {left frame n expand fillx} \
.frame11.bback {left frame nw} \
.frame11.lspeed {left frame n expand fillx} \
.frame11.bfor {left frame nw}
##########
# pack widget .
pack append . \
.frame0 {top frame center expand fillx} \
.frame8 {top frame center expand fillx} \
.frame3 {bottom frame center expand fillx} \
.frame10 {bottom frame center expand fillx} \
.frame11 {bottom frame center expand fillx}
}
# display/remove toplevel windows.
wm deiconify .
ShowWindow.